<%@ page import="com.lsk.util.UtilUUID" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/11/19
  Time: 0:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<div class="tcbox">
    <div class="tctit">我要参与</div>
    <div class="close" id="close" onclick="closeTcbox()">关闭</div>
    <p>请留下联系方式以便我们及时联系您！</p>
    <input type="text" id="name" placeholder="请输入姓名">
    <input type="text" id="tel" placeholder="请输入电话号码">
    <textarea id="address" placeholder="请输入地址">
        地址
    </textarea>
    <button style="margin-left: 16%";type="button" id="payId" onclick="groupPay('0') " >支付${money}元，立即参加</button>
</div>
<script>



    function groupPay(type) {

        $("#payId").attr('disabled',false);
        var tel=$("#tel").val();
        tel = $.trim(tel);

        var name=$.trim($("#name").val());
        if (name =="" || name==null || "null"==name){
            alert("请输入姓名");
            return false;
        }else {
            if(checkPhone(tel)==false){
                alert("手机号码有误，请重新填写");
                return false;
            }else{
                var index = layer.load();
                $.ajax({
                    url:'/mobileGroup/groupPay',
                    type:'POST', //GET
                    async:true,    //或false,是否异步
                    data:{
                        orgId:$("#orgId").val(),
                        activityId:$("#activityId").val(),
                        uuid:$("#uuid").val(),
                        type:type,
                        groupId:$("#groupId").val(),
                        name:name,
                        tel:tel
                    },
                    timeout:5000,    //超时时间
                    dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                    beforeSend:function(xhr){

                    },
                    success:function(dataA){
                        // $("#payDiv").append(data);
                        if (dataA.code=="000000"){
                            loadPayData();
                        }else{
                            alert(dataA.msg);
                            window.location.href="/mobileGroup/groupIndex?orgId=" +$("#orgId").val()+
                                "&activityId="+$("#activityId").val()+"&parentId="+$("#parentId").val()
                                +"&groupId="+$("#tempGroupId").val();
                        }
                        $("#payId").attr('disabled',true);
                    },
                    error:function(xhr,textStatus){
                        console.log('错误')
                        console.log(xhr)
                        console.log(textStatus)
                        $("#payId").attr('disabled',true);

                    },
                    complete:function(){
                        //console.log('结束')
                        $("#payId").attr('disabled',true);

                    }
                })
            }
        }

    }



    layui.use(['layer','element'], function(){
        var layer = layui.layer;
        var element = layui.element;
    });

    function checkPhone(phone){
        if(!(/^1[3456789]\d{9}$/.test(phone))){
            return false;
        }
    }



</script>